<?php


namespace App\Http\Requests\Customer\Entryorder;


use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreRequest extends FormRequest
{
    public function rules()
    {
        return [
            'foreign' => ['required', 'max:60', Rule::unique('entryorders')
                ->where('customer_id', $this->get('customer_id'))],
            'expect_at' => ['required', 'date'],
            'products' => ['required', 'array'],
            'products.*' => ['required', 'array'],
            'products.*.quantity' => ['required', 'integer'],
            'products.*.price' => ['required', 'numeric'],
            'products.*.sku' => ['required', Rule::exists('products', 'sku')],
        ];
    }
}
